import java.security.Security;
import java.util.Set;
import java.util.Map.Entry;

import collectors.email.services.GoogleService.OAuth2Provider;
import collectors.people.util.Config;

import com.typesafe.config.ConfigValue;

import play.*;
import util.AppState;

public class Global extends GlobalSettings {

	@Override
	public void onStart(Application app) {
		//TODO read config file for initial status
		AppState state = AppState.get();
		state.facebookRemoteCall = AppState.OpStatus.DISABLED;
		state.gmailRemoteCall = AppState.OpStatus.DISABLED;
		state.calendarRemoteCall = AppState.OpStatus.DISABLED;
		state.dropboxRemoteCall = AppState.OpStatus.DISABLED;
		
		Set<Entry<String,ConfigValue>> values = app.configuration().entrySet();
		try {
			Config.readConfig(values);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
		
		Security.addProvider(new OAuth2Provider());
	}
}
